<html>
<head><meta charset="utf-8"><title>possible to re-use private code from libcore within liballoc · t-compiler/help · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/index.html">t-compiler/help</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/possible.20to.20re-use.20private.20code.20from.20libcore.20within.20liballoc.html">possible to re-use private code from libcore within liballoc</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="176879125"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/possible%20to%20re-use%20private%20code%20from%20libcore%20within%20liballoc/near/176879125" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> timotree <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/possible.20to.20re-use.20private.20code.20from.20libcore.20within.20liballoc.html#176879125">(Sep 29 2019 at 17:03)</a>:</h4>
<p>I was reading the sort impls on slices and I noticed some duplicated logic. In libcore there's a function called <a href="https://github.com/rust-lang/rust/blob/18630677cf6c7ac50e6786c504b35bc09501dbe2/src/libcore/slice/sort.rs#L26" target="_blank" title="https://github.com/rust-lang/rust/blob/18630677cf6c7ac50e6786c504b35bc09501dbe2/src/libcore/slice/sort.rs#L26"><code>shift_head</code></a> that has exactly the same code as a function called <a href="https://github.com/rust-lang/rust/blob/18630677cf6c7ac50e6786c504b35bc09501dbe2/src/liballoc/slice.rs#L745" target="_blank" title="https://github.com/rust-lang/rust/blob/18630677cf6c7ac50e6786c504b35bc09501dbe2/src/liballoc/slice.rs#L745"><code>insert_head</code></a> in liballoc. Is there some way to de-duplicate this?</p>



<a name="177153161"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/possible%20to%20re-use%20private%20code%20from%20libcore%20within%20liballoc/near/177153161" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> timotree <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/possible.20to.20re-use.20private.20code.20from.20libcore.20within.20liballoc.html#177153161">(Oct 02 2019 at 14:08)</a>:</h4>
<p>to be clear, I'm just asking if it's possible to re-use private code from libcore within liballoc. If so, I would make a PR or something about this specific case.</p>



<a name="177153229"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/possible%20to%20re-use%20private%20code%20from%20libcore%20within%20liballoc/near/177153229" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/possible.20to.20re-use.20private.20code.20from.20libcore.20within.20liballoc.html#177153229">(Oct 02 2019 at 14:09)</a>:</h4>
<p>Those functions can probably be made public (you definitely can't reuse private code) and <code>#[doc(hidden)]</code> and unstable, so we can use them but no one else can (easily)</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>